**----------------------------
*** SES


destring pid3, replace



*** white versus blak

recode ppethm( 1=1) ( 2 3 4 5 = 0), gen(white)
recode ppethm( 1=0) ( 2  5 = 1) (3 4 = .), gen(black_W)


*** latino / immigrant 
recode ppethm( 1=0) ( 2 3 5 = .) (4 = 1), gen(latino_W)


recode minWS1 (2 3 4 = 0), gen(working)
*** 

gen minW_hourly = .
*** hourly wage peeps, currently working 
replace minW_hourly = 1 if working ==  1 &  minWQ2a == 1 
replace minW_hourly = 1 if working ==  1 &  minWQ3a == 16 
replace minW_hourly = 1 if working ==  1 &  minWQ4a == 1
replace minW_hourly = 2 if working ==  1 &  minWQ5a == 1
replace minW_hourly =3 if working ==  1 &  minWQ5a == 2

*** hourly wage peeps, currently not working 
replace minW_hourly = 1 if working ==  0 &  minWQ2b == 1 
replace minW_hourly = 1 if working ==  0 &  minWQ3b == 16 
replace minW_hourly = 1 if working ==  0 &  minWQ4b == 1
replace minW_hourly = 2 if working ==  0 &  minWQ5b == 1
replace minW_hourly =3 if working ==  0 &  minWQ5b == 2

*** hourly wage peeps, currently not working but someone in HH
replace minW_hourly = 1 if working ==  0 &  minW_Q2c == 1 
replace minW_hourly = 1 if working ==  0 &  minW_Q3c == 16 
replace minW_hourly = 1 if working ==  0 &  minW_Q4c == 1
replace minW_hourly = 2 if working ==  0 &  minW_Q5c == 1
replace minW_hourly =3 if working ==  0 &  minW_Q5c == 2


*** minW_hourly2
** = 1 if below $15/h
** = 2 if right above 15$/h
** = 3 if much above 15$/h

*** salary peeps
gen minW_hourly2 = minW_hourly
replace minW_hourly2 = 1 if working ==  1 &  minWsal1a == 1 
replace minW_hourly2 = 2 if working ==  1 &  minWsal2a == 1 
replace minW_hourly2 = 3 if working ==  1 &  minWsal2a == 2

replace minW_hourly2 = 1 if working ==  0 &  minW_sal1b == 1 
replace minW_hourly2 = 2 if working ==  0 &  minW_sal2b == 1 
replace minW_hourly2 = 3 if working == 0 &  minW_sal2b == 2

replace minW_hourly2 = 1 if working ==  0 &  minW_sal1c == 1 
replace minW_hourly2 = 2 if working ==  0 &  minW_sal2c == 1 
replace minW_hourly2 = 3 if working ==  0 &  minW_sal2c == 2

*** generate a common variable for both an indicator for salary/hourly/nobody working

gen minW = minW_hourly
replace minW = minW_hourly2 if minW == . 

gen type_minW = .
replace type_minW = 0 if minW_hourly2 < .
replace type_minW = 1 if minW_hourly < .



**** 
gen minW_hourly2a = (-1 *minW_hourly2) + 4
gen minW_hourlya = (-1 *minW_hourly) + 4

gen minWa = minW_hourlya
replace minWa = minW_hourly2a if minWa == . 






***** gun , = 2 if gun in the house and own it
**, = 1 if gun in the house but does not own it
** = 0 if no gun in the house 

gen gunO = 0 if xppp20117 == 2
replace gunO = 2 if xppp20117 == 1 & xppp20122 == 1
replace gunO = 1 if xppp20117 == 1 & xppp20122 == 2

gen gunOa = (-1*gunO)+ 4



** gay

recode xppalgb ( 1 3 4 = 1) (2 = 0), gen(gay)

*** vote

recode xpppa1690 ( 1=1) (2=2) (3= 3) ( 4 5 = 4), gen(vote16)


*** gender

rename ppgender sex


*** ethnicty 

gen whitea = 0 if white == 1
replace whitea = 1 if white == 0


*** party id

recode xparty7 ( 1 /3 = 0) (4 = .) (5/7 = 1), gen(dem)



*** religion 
recode xppp20071 ( 3 = .) (1=3), gen(evangelical)
recode evangelical ( 3 = 0) ( 2  = 1) , gen(Nevangelical)


*** reli2, add attendance
** = 3 if evangelical who goes once a week or more
gen reli2 = 3 if evangelical == 3 & XREL2 < 3
replace reli2 = 2 if evangelical == 3 & XREL2 == 3 
replace reli2 = 1 if evangelical == 3 & XREL2 == 4 
replace reli2 = 1 if evangelical == 3 & XREL2 == 5
replace reli2 = 1 if evangelical == 3 & XREL2 == 6
replace reli2 = 0 if evangelical == 2
replace reli2 = -1 if evangelical == 2 & XREL2 < 3



*** children

** do you want children?
gen childA = .
replace childA = 5 if childQ4 == 1 |  childQ3 == 1
replace childA = 0 if childQ4 == 3 |  childQ3 == 3
replace childA = 2 if childQ4 == 4 |  childQ3 == 4
replace childA = 4 if childQ4 == 2 |  childQ3 == 2

** do you have children?
gen childB = .
replace childB = 4 if childQ2 == 1 |  childQ2 == 3
replace childB = 3 if childQ2 == 4 
replace childB = 2 if childQ2 == 5 
replace childB = 1 if childQ2 == 6 
replace childB = 0 if childQ1 == 2

gen child = childA + childB

recode child ( 0 1 = 1) ( 2 3 = 2) ( 4 5 6 7 8 9 = 3), gen(child2)

*** income /hardship
factor black_W pprent ppincimp pphouse ppeducat
predict hardship1
 
factor black_W pprent ppincimp pphouse ppeducat minW_hourly2
predict hardship2


*** immi

recode  immiQ1 ( 1 2 3 = 0) (4 = 1), gen(FB)
recode immiQ2 (4 = .), gen(parents_immi)
recode immiQ3 (6 = .), gen(Gparents_immi)

factor FB parents_immi Gparents_immi
predict immiF



